package com.study.leetcode;

//https://leetcode.cn/problems/ugly-number/
public class Solution_263 {
    public static boolean isUgly(int n) {
        boolean f = true;
        while (f && n > 0) {
            f = false;
            if (n % 2 == 0) {
                n /= 2;
                f = true;
            }
            if (n % 3 == 0) {
                n /= 3;
                f = true;
            }
            if (n % 5 == 0) {
                n /= 5;
                f = true;
            }
        }
        return n == 1;
    }

    public static void main(String[] args) {
        boolean ugly = isUgly(0);
        System.out.println("ugly = " + ugly);
    }
}
